<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>test websocket</title>
</head>
<body>
<script charset="UTF-8">
    var ws = new WebSocket('ws://127.0.0.1:8080');
    ws.onopen = function () {
        setTimeout(function () {
            //ws.send(JSON.stringify({type: 1, authId: 100}));
            ws.send("martin123奥巴马");
        }, 1000)
    };
    ws.onmessage = function (e) {
        var h = document.createElement("h1");
        h.innerHTML = e.data;
        document.body.appendChild(h);
    };
    ws.onclose = function () {
        // alert("closed");
    };
    ws.onerror = function () {
        //alert("error happened");
    };

</script>
</body>
</html>